/**
 * Created by johnson on 17/4/27.
 */
import {Injectable} from '@angular/core';
import {TitleCpt} from "../lib/title/title.component";

@Injectable()
export class CONSTANT {
  genHomeTitleCptList():Array<TitleCpt> {
    let tmp:Array<TitleCpt>=[];
    tmp.push(new TitleCpt('APARTMENT','精品公寓','好房源那么多，我们为您精选'));
    tmp.push((new TitleCpt('STORIES','品牌故事')).setFontColor("#fff"));
    tmp.push(new TitleCpt('SERVICES','青果服务'));
    tmp.push((new TitleCpt(undefined,'关注公众号','关注微信，随时随地预约看房')).setFontColor("#90c31f"));
    return tmp;
  };

  genAboutTitleCptList():Array<TitleCpt>{
    let tmp:Array<TitleCpt>=[];
    tmp.push(new TitleCpt('LEADER','董事长介绍'));
    tmp.push(new TitleCpt('VISION','青果愿景'));
    tmp.push(new TitleCpt('MISSION','青果使命'));
    tmp.push((new TitleCpt('CORE_VALUE','青果核心价值')).setFontColor("#fff"));
    return tmp;
  }

  genCooperateTitleCptList():Array<TitleCpt>{
    let tmp:Array<TitleCpt>=[];
    tmp.push(new TitleCpt('SINCEREINVITATION','诚邀加盟','好房源那诚寻长江三角洲、杭州湾一线城市物业'));
    tmp.push(new TitleCpt('CLAIM','',''));
    tmp.push(new TitleCpt('HOTLINE','加盟热线','好房源那么多，我们为您精选'));
    return tmp;
  }

  genRentingMallTitleCptList():Array<TitleCpt>{
    let tmp:Array<TitleCpt>=[];
    tmp.push(new TitleCpt('RECOMMEND','租赁推荐','天青色等烟雨 而我在等你'));
    tmp.push(new TitleCpt('CLEANINGMALL','保洁商城','天青色等烟雨 而我在等你'));
    tmp.push(new TitleCpt('POINTSMALL','积分商城','天青色等烟雨 而我在等你'));
    return tmp;
  }

  genProjectDetailTitleCptList():Array<TitleCpt>{
    let tmp:Array<TitleCpt>=[];
    tmp.push(new TitleCpt('INTRODUCTION','项目介绍及特色','好房源那么多，我们为您精选'));
    tmp.push(new TitleCpt('ROOMTYPE','精品房型','好房源那么多，我们为您精选'));
    tmp.push(new TitleCpt('FACILITY','配套设施','好房源那么多，我们为您精选'));
    return tmp;
  }

  genRepairTitleCptList():Array<TitleCpt>{
    let tmp:Array<TitleCpt>=[];
    tmp.push(new TitleCpt('REPAIR','一键报修',' '));
    return tmp;
  }

  genPaymentTitleCptList():Array<TitleCpt>{
    let tmp:Array<TitleCpt>=[];
    tmp.push(new TitleCpt('PAYMENT','一键缴费',' '));
    return tmp;
  }
  genPlaceOrderTitleCptList():Array<TitleCpt>{
    let tmp:Array<TitleCpt>=[];
    tmp.push(new TitleCpt('LESSEE','承租人',''));
    tmp.push(new TitleCpt('TENANT','居住人',' '));
    return tmp;
  }

  genStoryViewTitleCptList():Array<TitleCpt>{
    let tmp:Array<TitleCpt>=[];
    tmp.push(new TitleCpt('STORIES','品牌故事','天青色等烟雨，而我在等你'));
    return tmp;
  }

  genRechargeTitleCptList():Array<TitleCpt>{
    let tmp:Array<TitleCpt>=[];
    tmp.push(new TitleCpt('RECHARGE','充值',''));
    return tmp;
  }

  navBarList:any = [
    {title: '首页', link: 'home'},
    {title: 'E租房', link: 'e-renting'},
    {title: '生活服务', link: 'life-service'},
    {title: '在线商城', link: 'renting-mall'},
    {title: '加盟合作', link: 'cooperate'},
    {title: '关于青果', link: 'about'}
  ];

  progressBarList:any= [
    {id:1,name:'选择房间'},
    {id:2,name:'提交订单'},
    {id:3,name:'签订合同'},
    {id:4,name:'确认支付'},
    {id:5,name:'完成支付'}
  ];
  progressBarList2:any= [
    {id:1,name:''},
    {id:2,name:''},
    {id:3,name:''},
    {id:4,name:'确认支付'},
    {id:5,name:'完成支付'}
  ];

  personalList:any = [
    {id: 1, menu: '我的资料', link: './'},
    {id: 2, menu: '我的预约', link: './mybooking'},
    {id: 3, menu: '我的租房', link: './myrenting'},
    {id: 4, menu: '我的维修', link: './myrepair'},
    {id: 5, menu: '我的保洁', link: './mycleaning'},
    {id: 6, menu: '我的租赁', link: './mylease'},
    {id: 7, menu: '生活缴费', link: './mylifepayment'},
    {id: 8, menu: '系统消息', link: './mysysmsg'},
    {id: 9, menu: '投诉建议', link: './mysuggestion'}
  ];

  leaseTimeItems:any=[
    {value:'',name:'请选择租期',isdisabled:false},
    {value:1,name:'1个月',isdisabled:false},
    {value:2,name:'3个月',isdisabled:false},
    {value:3,name:'6个月',isdisabled:false},
    {value:4,name:'1年',isdisabled:false},
    {value:5,name:'2年',isdisabled:false},
  ];

  // 招呼语
  getNewDate() {
    let now = new Date();
    let hour = now.getHours();
    if (hour < 6) {
      return  '凌晨好！';
    } else if (hour < 9) {
      return '早上好！';
    } else if (hour < 12) {
      return  '上午好！';
    } else if (hour < 14) {
      return  '中午好！';
    } else if (hour < 17) {
      return '下午好！';
    } else if (hour < 19) {
      return '傍晚好！';
    } else if (hour < 23) {
      return '晚上好！';
    } else {
      return '夜里好！';
    }
  }

  // 年月日拆分
  transformDate(date:any){
    let transDate = new Date(date);
    return {
      year:transDate.getFullYear(),
      month:transDate.getMonth()+1,
      date:transDate.getDate()
    }
  }

  // 人民币大写转换
  transformMoney(n) {
    if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(n))
      return "数据非法";
    let unit = "千百拾亿千百拾万千百拾元角分", str = "";
    n += "00";
    let p = n.indexOf('.');
    if (p >= 0)
      n = n.substring(0, p) + n.substr(p+1, 2);
    unit = unit.substr(unit.length - n.length);
    for (let i=0; i < n.length; i++)
      str += '零壹贰叁肆伍陆柒捌玖'.charAt(n.charAt(i)) + unit.charAt(i);
    return str.replace(/零(千|百|拾|角)/g, "零").replace(/(零)+/g, "零").replace(/零(万|亿|元)/g, "$1").replace(/(亿)万|壹(拾)/g, "$1$2").replace(/^元零?|零分/g, "").replace(/元$/g, "元整");
  }

  // 付款方式转换
  transformPayWay(str:any){
    let cycle:any;
    let payWay:any;
    switch (str){
      case 1:
        cycle = 3 ; payWay = '押一付三';
        break;
      case 2:
        cycle = 1 ; payWay = '押一付一';
        break;
      case 4:
        cycle = 4 ; payWay = '租赁贷';
        break;
    }
    return {
      cycle:cycle,
      payWay:payWay
    }
  }
}
